<template>
	<view class="content">
		<button class="size" @tap="createDownload">新建下载任务</button>
		<button class="size" @tap="clear">清除下载任务</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dtask: null
			}
		},
		onLoad() {

		},
		methods: {
			createDownload() {
				this.dtask = plus.downloader.createDownload("https://www.html5plus.org/doc/zh_cn/downloader.html", {}, function(d, status) {
					// 下载完成
					if (status == 200) {
						console.log("Download success: " + d.filename);
					} else {
						console.log("Download failed: " + status);
					}
				});
				this.dtask.start();
			},
			clear(){
				plus.downloader.clear();
			}

		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.size {
		margin: 30rpx 0;
	}
</style>
